#ifndef __SINGLETON_H__
#define __SINGLETON_H__

namespace GCRE {

	template <class T>
	class Singleton {
		public:
			static T* Instance();
			
		protected:
			Singleton();
			static auto_ptr<T> m_Instance;
		private:
	};

	template <class T>
	T* Singleton<T>::Instance()
	{
		if ( m_Instance.get() == NULL )
		{
			m_Instance.reset( new T() );
		}
		return m_Instance.get();
	}

	template<class T>   
	auto_ptr<T>   Singleton<T>::m_Instance;   
}

#endif	//	__SINGLETON_H__